import type { UploadResponse } from "@/types/common";
import service, { request } from "@/utils/reuqest";

/**
 * 上传文件
 */
export const uploadFileAPI = (params: FormData) =>
  request<UploadResponse>("/upload", "POST", params);

/**
 * 下载文件
 */

export const downloadFileAPI = (id: number) => {
  // 第二个范型参数为 Blob
  return service<null, Blob>({
    method: 'GET',
    url: `/download/${id}`,
    responseType: 'blob' // 把二进制数据流转换成 blob 对象，用于下载
  })
}